package com.haochang.chunkvod.model.order;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import com.haochang.base.BaseActivity;
import com.haochang.chunkvod.app.common.VodConstant;
import com.haochang.chunkvod.app.common.intent.IntentKey;
import com.haochang.chunkvod.app.config.ApiConfig;
import com.haochang.chunkvod.app.config.ServerConfig;
import com.haochang.chunkvod.app.database.order.BaseInfoDao;
import com.haochang.chunkvod.app.database.order.PartInfoDao;
import com.haochang.chunkvod.app.utils.CollectionUtils;
import com.haochang.chunkvod.app.utils.HelperUtils;
import com.haochang.chunkvod.app.utils.ToastUtils;
import com.haochang.chunkvod.model.BaseInfo;
import com.haochang.chunkvod.model.PhotoDetailInfo;
import com.haochang.chunkvod.model.hostess.ConsumeInfo;
import com.haochang.chunkvod.model.hostess.GoodsFeeInfo;
import com.haochang.chunkvod.model.order.query.GroupGoodsInfo;
import com.haochang.chunkvod.model.order.query.OrderInfo;
import com.haochang.chunkvod.tools.thirdparty.network.http.httpenum.HttpCacheEnum;
import com.haochang.chunkvod.tools.thirdparty.network.http.httpenum.HttpMethodEnum;
import com.haochang.chunkvod.tools.thirdparty.network.http.httpenum.HttpRequestLoadingEnum;
import com.haochang.chunkvod.tools.thirdparty.network.http.request.HttpRequestBuilder;
import com.haochang.chunkvod.tools.thirdparty.network.http.request.HttpRequestTask;
import com.haochang.chunkvod.tools.thirdparty.network.http.request.HttpRequestBuilder.IHttpRequestSucessListener;
import com.haochang.chunkvod.tools.vod.other.MaxIntegerUtil;

import android.text.TextUtils;

/**
 * @author qintao
 *         created at 2016/6/15 11:01
 *         点餐数据请求
 */

public class OrderData
{
	private BaseActivity context;

	public OrderData(BaseActivity context)
	{
		this.context = context;
	}

	public interface IRoomStatusListener
	{
		void onRequestSuccess(int task_order_count, List<RoomInfo> list, boolean clear);

		void onFinish();
	}

	public interface IMenuListener
	{
		void onRequestSuccess(List<MenuInfo> list);
	}

	public interface IOrderFoodListener
	{
		void onRequestSuccess(List<GoodsInfo> list, boolean clear, int is_active);

		void onFinish();
	}

	public interface IOrderGoodDetailListener
	{
		void onRequestSuccess(GoodsInfo info);
	}

	public interface IOrderSearchListener
	{
		void onRequestSuccess(List<OrderInfo> list);
	}

	public interface IBillProfileListener
	{
		void onRequestSuccess(ConsumeInfo info);

		void onFail(int errno, String errMsg);
	}

	public interface IDeskFreeListener
	{
		void onRequestSuccess();

		void onFail(int errno, String errMsg);
	}

	public interface ResultListListener<T>
	{
		void onRequestSuccess(List<T> list);

		void onFail(int errno, String errMsg);
	}

	public interface ResultResponseList<T>
	{
		void onRequestSuccess(List<T> list);

		void onFail(int errno, String errMsg);
	}

	public interface ResultResponse
	{
		void onRequestSuccess();

		void onFail(int errorNo, String errorMsg);
	}

	public interface ITableOrderPrintDataListener
	{
		void onRequestSuccess();

		void onFail(int errorNo, String errorMsg);
	}

	/**
	 * 基础信息获取
	 */
	public void requestBaseInfo()
	{
		HttpRequestTask httpRequestTask = new HttpRequestBuilder(context).interfaceName(ApiConfig.VOD_BASE).param(null).httpMethodEnum(HttpMethodEnum.GET)
				.localCache(HttpCacheEnum.ENABLE_VALID).httpRequestLoadingEnum(HttpRequestLoadingEnum.HTTP_LOADING_DEFAULT)
				.httpRequestSucessListener(new IHttpRequestSucessListener()
				{

					@Override
					public void onResponseSucess(JSONObject jsonObject)
					{
						if (jsonObject != null)
						{
							parseAreaJson(jsonObject);
							parseBaseInfoJson(jsonObject);
							JSONObject object = jsonObject.optJSONObject("branch");
							if (null != object)
								HelperUtils.getHelperInstance().setValue(IntentKey.SHOP_NAME, object.optString("name"));
							JSONObject object1 = jsonObject.optJSONObject("device");
							if (null == object1)
								HelperUtils.getHelperInstance().setValue(IntentKey.IS_GET_PRINT_INFO, false);
							else
							{
								HelperUtils.getHelperInstance().setValue(IntentKey.DEVICE_NAME, object1.optString("name"));
								HelperUtils.getHelperInstance().setValue(IntentKey.IS_GET_PRINT_INFO, true);
							}
						}
					}
				}).httpRequestFailedListener(new HttpRequestBuilder.IHttpRequestFailedListener()
				{

					@Override
					public void onError(int errno, String errMsg)
					{
						ToastUtils.showText(context, "获取基础信息失败");
						HelperUtils.getHelperInstance().setValue(IntentKey.IS_GET_PRINT_INFO, false);
					}
				}).build();
		httpRequestTask.execute();
	}

	/**
	 * 包房使用状态请求
	 *
	 * @param areaIds     区域IDS
	 * @param sort_type   sort_type排序方式
	 * @param isLoading   是否加载转圈
	 * @param isShowTable isShowTable 是否显示桌台
	 * @param listener    网络请求监听
	 */
	public void requestRoomStatus(String areaIds, String sort_type, boolean isLoading, final boolean isShowTable, final IRoomStatusListener listener)
	{
		JSONArray jsonArray = new JSONArray();
		if (!TextUtils.isEmpty(areaIds))
		{
			String[] area_ids = areaIds.split(",");
			for (int i = 0; i < area_ids.length; i++)
			{
				if (!TextUtils.isEmpty(area_ids[i]))
					jsonArray.put(area_ids[i]);
			}
		}
		HashMap<String, String> map = new HashMap<String, String>();
		map.put("area_ids", jsonArray.toString());
		map.put("sort_type", String.valueOf(sort_type));
		HttpRequestTask httpRequestTask = new HttpRequestBuilder(context).interfaceName(isShowTable ? ApiConfig.ORDER_DESK_STATUS : ApiConfig.ORDER_ROOM_STATUS)
				.param(map).httpMethodEnum(HttpMethodEnum.GET).localCache(HttpCacheEnum.ENABLE_VALID)
				.httpRequestLoadingEnum(isLoading ? HttpRequestLoadingEnum.HTTP_LOADING_DEFAULT : HttpRequestLoadingEnum.HTTP_LOADING_NONE)
				.httpRequestSucessListener(new IHttpRequestSucessListener()
				{

					@Override
					public void onResponseSucess(JSONObject jsonObject)
					{
						if (jsonObject != null)
						{
							List<RoomInfo> list = (isShowTable ? parseDeskJson(jsonObject) : parseRoomJson(jsonObject));
							int task_order_count = (isShowTable ? jsonObject.optInt("notify_count") : jsonObject.optInt("task_order_count"));
							if (listener != null)
							{
								listener.onRequestSuccess(0, list, true);
								listener.onFinish();
							}
						}
					}
				}).httpRequestFailedListener(new HttpRequestBuilder.IHttpRequestFailedListener()
				{

					@Override
					public void onError(int errno, String errMsg)
					{
						if (null != listener)
						{
							listener.onFinish();
						}
					}
				}).build();
		httpRequestTask.execute();
	}

	/**
	 * 菜单请求
	 *
	 * @param billId   账单id
	 * @param listener 网络请求监听
	 */
	public void requestMenu(String billId, final IMenuListener listener)
	{
		HashMap<String, String> map = new HashMap<String, String>();
		if (!TextUtils.equals(billId, VodConstant.TAKEOUT_BILLID) && !TextUtils.isEmpty(billId))//外带不传bill_id
			map.put("bill_id", billId);
		HttpRequestTask httpRequestTask = new HttpRequestBuilder(context).interfaceName(ApiConfig.MENU).param(map).httpMethodEnum(HttpMethodEnum.GET)
				.httpRequestLoadingEnum(HttpRequestLoadingEnum.HTTP_LOADING_NONE).httpRequestSucessListener(new HttpRequestBuilder.IHttpRequestSucessListener()
				{

					@Override
					public void onResponseSucess(JSONObject jsonObject)
					{

						if (jsonObject != null)
						{
							List<MenuInfo> list = parseMenuJson(jsonObject);
							if (listener != null)
							{
								listener.onRequestSuccess(list);
							}
						}
					}
				}).build();
		httpRequestTask.execute();
	}

	/**
	 * 点餐主页列表请求
	 *
	 * @param menuId    菜单id
	 * @param roomId    房间id
	 * @param billId    账单id
	 * @param isLoading 是否加载转圈
	 * @param offset    分页偏移量
	 * @param listener  网络请求监听
	 */
	public void requestOrderFood(final String menuId, final String roomId, final String billId, boolean isLoading, final String offset,
			final IOrderFoodListener listener)
	{
		HashMap<String, String> map = new HashMap<String, String>();
		if (!TextUtils.equals(billId, VodConstant.TAKEOUT_BILLID) && !TextUtils.isEmpty(billId))//外带不传bill_id
			map.put("bill_id", billId);
		if (!TextUtils.isEmpty(menuId))
			map.put("menu_type_id", menuId);
		if (!TextUtils.isEmpty(offset))
			map.put("offset", offset);
		else
			map.put("offset", "0");
		map.put("page_size", "25");
		HttpRequestTask httpRequestTask = new HttpRequestBuilder(context).interfaceName(ApiConfig.GOODLISTS).param(map).httpMethodEnum(HttpMethodEnum.GET)
				.isPullToRefresh(!"0".equals(offset)).localCache(HttpCacheEnum.ENABLE_VALID)
				.httpRequestLoadingEnum(isLoading ? HttpRequestLoadingEnum.HTTP_LOADING_DEFAULT : HttpRequestLoadingEnum.HTTP_LOADING_NONE)
				.httpRequestSucessListener(new HttpRequestBuilder.IHttpRequestSucessListener()
				{

					@Override
					public void onResponseSucess(JSONObject jsonObject)
					{
						if (jsonObject != null)
						{
							List<GoodsInfo> list = parseGoodsJson(jsonObject, roomId, menuId, billId);
							int is_active = jsonObject.optInt("is_active");
							if (listener != null)
							{
								if (!TextUtils.isEmpty(offset) && offset.equals("0"))
								{
									listener.onRequestSuccess(list, true, is_active);
								} else
								{
									listener.onRequestSuccess(list, false, is_active);
								}
								listener.onFinish();
							}

						}
					}
				}).httpRequestFailedListener(new HttpRequestBuilder.IHttpRequestFailedListener()
				{

					@Override
					public void onError(int errno, String errMsg)
					{
						if (null != listener)
						{
							listener.onFinish();
						}
					}
				}).build();
		httpRequestTask.execute();
	}

	/**
	 * 点餐主页收索列表请求
	 *
	 * @param active    0商品1活动
	 * @param keyword   搜索关键字
	 * @param roomId    房间id
	 * @param isLoading 是否加载转圈
	 * @param offset    分页偏移量
	 * @param listener  网络请求监听
	 */
	public void requestSearchOrderFood(String active, String charging_room_type_id, String keyword, final String roomId, final String bill_id,
			boolean isLoading, final String offset, final IOrderFoodListener listener)
	{
		HashMap<String, String> map = new HashMap<String, String>();
		map.put("key_word", keyword);
		if (!TextUtils.isEmpty(offset))
			map.put("offset", offset);
		else
			map.put("offset", "0");
		map.put("page_size", "25");
		map.put("is_active", active);
		if (!TextUtils.isEmpty(charging_room_type_id))
			map.put("room_type_id", charging_room_type_id);
		HttpRequestTask httpRequestTask = new HttpRequestBuilder(context).interfaceName(ApiConfig.SEARCH).param(map).httpMethodEnum(HttpMethodEnum.GET)
				.isPullToRefresh(!"0".equals(offset)).localCache(HttpCacheEnum.ENABLE_VALID)
				.httpRequestLoadingEnum(isLoading ? HttpRequestLoadingEnum.HTTP_LOADING_DEFAULT : HttpRequestLoadingEnum.HTTP_LOADING_NONE)
				.httpRequestSucessListener(new HttpRequestBuilder.IHttpRequestSucessListener()
				{

					@Override
					public void onResponseSucess(JSONObject jsonObject)
					{
						if (jsonObject != null)
						{
							int is_active = jsonObject.optInt("is_active");
							List<GoodsInfo> list = parseGoodsJson(jsonObject, roomId, "", bill_id);
							if (listener != null)
							{
								if (!TextUtils.isEmpty(offset) && offset.equals("0"))
								{
									listener.onRequestSuccess(list, true, is_active);
								} else
								{
									listener.onRequestSuccess(list, false, is_active);
								}
								listener.onFinish();
							}
						}
					}
				}).httpRequestFailedListener(new HttpRequestBuilder.IHttpRequestFailedListener()
				{

					@Override
					public void onError(int errno, String errMsg)
					{
						if (null != listener)
						{
							listener.onFinish();
						}
					}
				}).build();
		httpRequestTask.execute();
	}

	/**
	 * 套餐详情请求
	 *
	 * @param good_id  商品id
	 * @param roomId   房间id
	 * @param listener 网络请求监听
	 */
	public void requestGoodsDetailFood(String good_id, final String roomId, final IOrderGoodDetailListener listener)
	{
		HashMap<String, String> map = new HashMap<String, String>();
		map.put("goods_id", good_id);
		HttpRequestTask httpRequestTask = new HttpRequestBuilder(context).interfaceName(ApiConfig.GOODSDETAIL).param(map).httpMethodEnum(HttpMethodEnum.GET)
				.httpRequestLoadingEnum(HttpRequestLoadingEnum.HTTP_LOADING_NONE).httpRequestSucessListener(new HttpRequestBuilder.IHttpRequestSucessListener()
				{

					@Override
					public void onResponseSucess(JSONObject jsonObject)
					{
						if (jsonObject != null)
						{
							GoodsInfo info = parseGoodsDetailJson(jsonObject, roomId);
							if (listener != null)
							{
								listener.onRequestSuccess(info);
							}
						}
					}
				}).build();
		httpRequestTask.execute();
	}

	/**
	 * 活动详情请求
	 *
	 * @param active_id 活动id
	 * @param roomId    房间id
	 * @param listener  网络请求监听
	 */
	public void requestActiveDetailFood(String active_id, final String roomId, final IOrderGoodDetailListener listener)
	{
		HashMap<String, String> map = new HashMap<String, String>();
		map.put("active_id", active_id);
		map.put("room_id", roomId);
		HttpRequestTask httpRequestTask = new HttpRequestBuilder(context).interfaceName(ApiConfig.ACTIVE_DETAIL).param(map).httpMethodEnum(HttpMethodEnum.GET)
				.httpRequestLoadingEnum(HttpRequestLoadingEnum.HTTP_LOADING_NONE).httpRequestSucessListener(new HttpRequestBuilder.IHttpRequestSucessListener()
				{

					@Override
					public void onResponseSucess(JSONObject jsonObject)
					{
						if (jsonObject != null)
						{
							GoodsInfo info = parseActiveDetailJson(jsonObject, roomId);
							if (listener != null)
							{
								listener.onRequestSuccess(info);
							}
						}
					}
				}).build();
		httpRequestTask.execute();
	}

	/**
	 * 桌台转换为空桌台
	 *
	 * @param desk_id
	 * @param listener
	 */
	public void requestDeskFree(String desk_id, String bill_id, final IDeskFreeListener listener)
	{
		HashMap<String, String> map = new HashMap<String, String>();
		map.put("desk_id", desk_id);
		map.put("bill_id", bill_id);
		map.put("force", "0");
		HttpRequestTask httpRequestTask = new HttpRequestBuilder(context).interfaceName(ApiConfig.ORDER_DESK_FREE).param(map)
				.httpMethodEnum(HttpMethodEnum.POST).httpRequestLoadingEnum(HttpRequestLoadingEnum.HTTP_LOADING_DEFAULT)
				.httpRequestSucessListener(new HttpRequestBuilder.IHttpRequestSucessListener()
				{

					@Override
					public void onResponseSucess(JSONObject jsonObject)
					{
						if (null != listener)
						{
							listener.onRequestSuccess();
						}
					}
				}).httpRequestFailedListener(new HttpRequestBuilder.IHttpRequestFailedListener()
				{

					@Override
					public void onError(int errno, String errMsg)
					{
						if (null != listener)
						{
							listener.onFail(errno, errMsg);
						}
					}
				}).build();
		httpRequestTask.execute();
	}

	/**
	 * 点餐查询请求
	 *
	 * @param bill_id  账单id
	 * @param listener 网络请求监听
	 */
	public void requestOrderSearch(String bill_id, final IOrderSearchListener listener)
	{
		HashMap<String, String> map = new HashMap<String, String>();
		map.put("bill_id", bill_id);
		HttpRequestTask httpRequestTask = new HttpRequestBuilder(context).interfaceName(ApiConfig.GOODS_HISTORY).param(map).httpMethodEnum(HttpMethodEnum.GET)
				.httpRequestLoadingEnum(HttpRequestLoadingEnum.HTTP_LOADING_DEFAULT)
				.httpRequestSucessListener(new HttpRequestBuilder.IHttpRequestSucessListener()
				{

					@Override
					public void onResponseSucess(JSONObject jsonObject)
					{
						if (jsonObject != null)
						{
							List<OrderInfo> list = parseOrderQueryJson(jsonObject);
							if (listener != null)
							{
								listener.onRequestSuccess(list);
							}
						}
					}
				}).build();
		httpRequestTask.execute();
	}

	/**
	 * 点餐--外带--查询请求
	 *
	 * @param bill_id  账单id
	 * @param listener 网络请求监听
	 */
	public void requestOrderTakeOutSearch(String bill_id, final IOrderSearchListener listener)
	{
		HashMap<String, String> map = new HashMap<String, String>();
		if (!TextUtils.equals(bill_id, VodConstant.TAKEOUT_BILLID))
			map.put("bill_id", bill_id);
		HttpRequestTask httpRequestTask = new HttpRequestBuilder(context).interfaceName(ApiConfig.GOODS_TAKEOUT_HISTORY).param(map)
				.httpMethodEnum(HttpMethodEnum.GET).httpRequestLoadingEnum(HttpRequestLoadingEnum.HTTP_LOADING_DEFAULT)
				.httpRequestSucessListener(new HttpRequestBuilder.IHttpRequestSucessListener()
				{

					@Override
					public void onResponseSucess(JSONObject jsonObject)
					{
						if (jsonObject != null)
						{
							List<OrderInfo> list = parseOrderTakeOutHistoryList(jsonObject);
							if (listener != null)
							{
								listener.onRequestSuccess(list);
							}
						}
					}
				}).build();
		httpRequestTask.execute();
	}

	/**
	 * 获取消费详情
	 *
	 * @param listListener
	 * @return
	 */
	public void requestBillProfileInfo(String billId, final IBillProfileListener listListener)
	{
		HashMap<String, String> map = new HashMap<String, String>();
		map.put("bill_id", billId);
		new HttpRequestBuilder(context).interfaceName(ApiConfig.ORDER_BILL_PROFILE).param(map).httpMethodEnum(HttpMethodEnum.GET)
				.localCache(HttpCacheEnum.ENABLE_VALID).httpRequestLoadingEnum(HttpRequestLoadingEnum.HTTP_LOADING_DEFAULT)
				.httpRequestSucessListener(new IHttpRequestSucessListener()
				{
					@Override
					public void onResponseSucess(JSONObject jsonObject)
					{
						if (jsonObject != null)
						{
							ConsumeInfo info = paraseConsumeInfoJson(jsonObject);
							if (listListener != null)
							{
								listListener.onRequestSuccess(info);
							}
						}
					}
				}).httpRequestFailedListener(new HttpRequestBuilder.IHttpRequestFailedListener()
				{

					@Override
					public void onError(int errno, String errMsg)
					{
						if (null != listListener)
						{
							listListener.onFail(errno, errMsg);
						}
					}
				}).build().execute();
	}

	/**
	 * 获取预结列表
	 */
	@SuppressWarnings("unchecked")
	public void requestExpectedList(boolean showLoadingAnimation, final ResultResponseList listener)
	{
		HashMap<String, String> map = new HashMap<String, String>();
		HttpRequestTask httpRequestTask = new HttpRequestBuilder(context).interfaceName(ApiConfig.ORDER_EXPECTED).param(map).httpMethodEnum(HttpMethodEnum.GET)
				.httpRequestLoadingEnum(showLoadingAnimation ? HttpRequestLoadingEnum.HTTP_LOADING_DEFAULT : HttpRequestLoadingEnum.HTTP_LOADING_NONE)
				.httpRequestSucessListener(new HttpRequestBuilder.IHttpRequestSucessListener()
				{
					@Override
					public void onResponseSucess(JSONObject jsonObject)
					{
						if (jsonObject != null)
						{
							List<RoomInfo> list = parseExectedList(jsonObject);
							if (listener != null)
								listener.onRequestSuccess(list);
						}
					}
				}).httpRequestFailedListener(new HttpRequestBuilder.IHttpRequestFailedListener()
				{
					@Override
					public void onError(int errno, String errMsg)
					{
						if (listener != null)
							listener.onFail(errno, errMsg);
					}
				}).build();
		httpRequestTask.execute();
	}

	/**
	 * 获取点餐--备注列表
	 */
	@SuppressWarnings("unchecked")
	public void requestOrderRemarkList(final ResultResponseList listener)
	{
		HashMap<String, String> map = new HashMap<String, String>();
		HttpRequestTask httpRequestTask = new HttpRequestBuilder(context).interfaceName(ApiConfig.ORDER_REMARK_LIST).param(map)
				.httpMethodEnum(HttpMethodEnum.GET).httpRequestLoadingEnum(HttpRequestLoadingEnum.HTTP_LOADING_DEFAULT)
				.httpRequestSucessListener(new HttpRequestBuilder.IHttpRequestSucessListener()
				{
					@Override
					public void onResponseSucess(JSONObject jsonObject)
					{
						if (jsonObject != null)
						{
							if (listener != null)
								listener.onRequestSuccess(parseRemarkJson(jsonObject));
						}
					}
				}).httpRequestFailedListener(new HttpRequestBuilder.IHttpRequestFailedListener()
				{
					@Override
					public void onError(int errno, String errMsg)
					{
						if (listener != null)
							listener.onFail(errno, errMsg);
					}
				}).build();
		httpRequestTask.execute();
	}

	/**
	 * 删除预结列表item项
	 */
	@SuppressWarnings("unchecked")
	public void requestDeleteExpectedItem(String roomId, final ResultResponse listener)
	{
		HashMap<String, String> map = new HashMap<String, String>();
		map.put("room_id", roomId);
		HttpRequestTask httpRequestTask = new HttpRequestBuilder(context).interfaceName(ApiConfig.ORDER_EXPECTED).param(map)
				.httpMethodEnum(HttpMethodEnum.DELETE).httpRequestLoadingEnum(HttpRequestLoadingEnum.HTTP_LOADING_DEFAULT)
				.httpRequestSucessListener(new HttpRequestBuilder.IHttpRequestSucessListener()
				{
					@Override
					public void onResponseSucess(JSONObject jsonObject)
					{
						if (jsonObject != null)
						{
							if (listener != null)
								listener.onRequestSuccess();
						}
					}
				}).httpRequestFailedListener(new HttpRequestBuilder.IHttpRequestFailedListener()
				{
					@Override
					public void onError(int errno, String errMsg)
					{
						if (listener != null)
							listener.onFail(errno, errMsg);
					}
				}).build();
		httpRequestTask.execute();
	}

	/**
	 * 已点列表列印小票
	 */
	public void requestPrintData(String bill_id, final ITableOrderPrintDataListener listener)
	{
		HashMap<String, String> map = new HashMap<String, String>();
		map.put("bill_id", bill_id);
		HttpRequestTask httpRequestTask = new HttpRequestBuilder(context).interfaceName(ApiConfig.ORDER_TABLE_PRINT_DATA).param(map)
				.httpMethodEnum(HttpMethodEnum.POST).httpRequestLoadingEnum(HttpRequestLoadingEnum.HTTP_LOADING_DEFAULT)
				.httpRequestSucessListener(new HttpRequestBuilder.IHttpRequestSucessListener()
				{

					@Override
					public void onResponseSucess(JSONObject jsonObject)
					{
						if (listener != null)
						{
							listener.onRequestSuccess();
						}
					}
				}).httpRequestFailedListener(new HttpRequestBuilder.IHttpRequestFailedListener()
				{
					@Override
					public void onError(int errno, String errMsg)
					{
						if (listener != null)
							listener.onFail(errno, errMsg);
					}
				}).build();
		httpRequestTask.execute();
	}

	/**
	 * 消费办法---图片列表
	 */
	public void requestPictureList(final ResultListListener listener)
	{
		HttpRequestTask httpRequestTask = new HttpRequestBuilder(context).interfaceName(ApiConfig.PICTURE_LIST).param(null).httpMethodEnum(HttpMethodEnum.GET)
				.httpRequestLoadingEnum(HttpRequestLoadingEnum.HTTP_LOADING_DEFAULT)
				.httpRequestSucessListener(new HttpRequestBuilder.IHttpRequestSucessListener()
				{

					@Override
					public void onResponseSucess(JSONObject jsonObject)
					{
						if (listener != null)
						{
							List list = parsePictureList(jsonObject);
							listener.onRequestSuccess(list);
						}
					}
				}).httpRequestFailedListener(new HttpRequestBuilder.IHttpRequestFailedListener()
				{
					@Override
					public void onError(int errno, String errMsg)
					{
						if (listener != null)
							listener.onFail(errno, errMsg);
					}
				}).build();
		httpRequestTask.execute();
	}

	/**
	 * 解析基本信息
	 *
	 * @return
	 */
	private void parseBaseInfoJson(JSONObject jsonObject)
	{
		if (jsonObject == null)
			return;
		List<BaseInfo> baseInfoList = new ArrayList<BaseInfo>();
		Iterator keysFirst = jsonObject.keys();//第一层keys
		while (keysFirst.hasNext())
		{
			String stringFirst = (String) keysFirst.next();
			if (!TextUtils.equals(stringFirst, "room_list_color") && !TextUtils.equals(stringFirst, "desk_list_color"))//不是房间而且不是桌台字段就过滤
				continue;
			JSONObject jsonObjectFirst = jsonObject.optJSONObject(stringFirst);//第一层jsonObject
			if (jsonObjectFirst != null)
			{
				Iterator keysSecond = jsonObjectFirst.keys();//第二层keys
				while (keysSecond.hasNext())
				{
					String stringSecond = (String) keysSecond.next();
					JSONObject jsonObjectSecond = jsonObjectFirst.optJSONObject(stringSecond);//第二层jsonObject
					if (jsonObjectSecond != null && jsonObjectSecond.has("background"))
					{//含background就表示是最后一层了，不需要再往下解析,否则解析第三层
						BaseInfo infoSecond = new BaseInfo();
						infoSecond.setRoom(stringFirst.contains("room"));//第二层返回background的
						infoSecond.setRoomStatus(stringSecond);
						infoSecond.setRoomUsage(stringSecond);
						infoSecond.setRoomBgColor(jsonObjectSecond.optString("background"));
						infoSecond.setRoomBorderColor(jsonObjectSecond.optString("border"));
						infoSecond.setRoomTag(jsonObjectSecond.optString("tag"));
						baseInfoList.add(infoSecond);
					} else if (jsonObjectSecond != null)
					{
						Iterator keysThird = jsonObjectSecond.keys();//第三层keys
						while (keysThird.hasNext())
						{
							String stringThird = (String) keysThird.next();
							JSONObject jsonObjectThird = jsonObjectSecond.optJSONObject(stringThird);//第三层jsonObject
							if (jsonObjectThird != null)
							{
								BaseInfo infoThird = new BaseInfo();
								infoThird.setRoom(stringFirst.contains("room"));//第三层返回background的
								infoThird.setRoomStatus(stringSecond);//用第二次key标示状态
								infoThird.setRoomUsage(stringThird);//用第三层key标示用途
								infoThird.setRoomBgColor(jsonObjectThird.optString("background"));
								infoThird.setRoomBorderColor(jsonObjectThird.optString("border"));
								infoThird.setRoomTag(jsonObjectThird.optString("tag"));
								baseInfoList.add(infoThird);
							}
						}
					}
				}
			}
		}
		try
		{
			if (!CollectionUtils.isEmpty(baseInfoList))
			{
				BaseInfoDao.getDao().clearTable(BaseInfo.class);
				BaseInfoDao.getDao().insertAll(BaseInfo.class, baseInfoList);
			}
		} catch (Exception e)
		{
			e.printStackTrace();
		}
	}

	/**
	 * 解析消费商品
	 *
	 * @return
	 */
	private ConsumeInfo paraseConsumeInfoJson(JSONObject jsonObject)
	{
		if (jsonObject == null)
			return null;
		ConsumeInfo info = new ConsumeInfo();
		info.setCustomer_count(jsonObject.optInt("people_count"));
		info.setRoom_fee(jsonObject.optInt("room_fee"));
		info.setBegin_time(jsonObject.optString("charging_begin_time"));
		info.setConsume_long(jsonObject.optInt("consume_long"));
		info.setEach_fee(jsonObject.optInt("each_fee"));
		JSONArray array = jsonObject.optJSONArray("goods_info");
		info.setAllowance_fee(jsonObject.optInt("allowance_fee"));
		info.setTotalPrice(jsonObject.optInt("receivable_fee"));
		ArrayList<GoodsFeeInfo> infoList = new ArrayList<GoodsFeeInfo>();
		if (array != null && array.length() > 0)
		{
			int len = array.length();
			for (int i = 0; i < len; i++)
			{
				JSONObject o = array.optJSONObject(i);
				GoodsFeeInfo goodsFeeInfo = new GoodsFeeInfo();
				parseRetailInfo(goodsFeeInfo, o);
				infoList.add(goodsFeeInfo);
			}
			info.setGoodsFeeInfos(infoList);
		}
		return info;
	}

	/**
	 * 递归处理账单里面的商品
	 *
	 * @param info       GoodsFeeInfo
	 * @param jsonObject JSONObject
	 */
	private void parseRetailInfo(GoodsFeeInfo info, JSONObject jsonObject)
	{
		info.setCount(jsonObject.optInt("quantity"));
		info.setGoodsName(jsonObject.optString("name"));
		info.setIs_give(jsonObject.optInt("is_present") == 1);
		//		info.setPrice(jsonObject.optInt("unit_price"));//单价
		info.setMoney(jsonObject.optInt("sum"));
		info.setUnit(TextUtils.equals(jsonObject.optString("unit"), "0") ? "套" : jsonObject.optString("unit"));
		info.setType(!TextUtils.isEmpty(jsonObject.optString("bill_retail_id")) ? 0 : (!TextUtils.isEmpty(jsonObject.optString("bill_bundle_id")) ? 1 : 2));
		JSONArray jsonArray = jsonObject.optJSONArray("goods");
		if (null != jsonArray && jsonArray.length() > 0)
		{
			int lenth = jsonArray.length();
			for (int j = 0; j < lenth; j++)
			{
				JSONObject jsonObject1 = jsonArray.optJSONObject(j);
				if (null != jsonObject1)
				{
					GoodsFeeInfo goodsFeeInfo = new GoodsFeeInfo();
					goodsFeeInfo.setType(!TextUtils.isEmpty(jsonObject1.optString("bill_retail_id")) ? 0
							: (!TextUtils.isEmpty(jsonObject1.optString("bill_bundle_id")) ? 1 : 2));
					parseRetailInfo(goodsFeeInfo, jsonObject1);
					info.getArrayList().add(goodsFeeInfo);
				}
			}
		}
	}

	/**
	 * 解析菜单
	 *
	 * @param jsonObject jsonObject
	 * @return 菜单信息
	 */
	private List<MenuInfo> parseMenuJson(JSONObject jsonObject)
	{
		ArrayList<MenuInfo> menuInfoList = new ArrayList<MenuInfo>();
		JSONArray jsonArray = jsonObject.optJSONArray("menus");
		if (jsonArray != null && jsonArray.length() > 0)
		{
			for (int i = 0; i < jsonArray.length(); i++)
			{
				JSONObject jObject = jsonArray.optJSONObject(i);
				if (jObject == null)
					continue;
				MenuInfo info = new MenuInfo();
				info.setMenuId(jObject.optString("menu_type_id"));
				info.setMenuName(jObject.optString("menu_type_name"));
				info.setMenuWeight(jObject.optInt("weight"));
				info.setIs_present(jObject.optInt("is_present"));
				menuInfoList.add(info);
			}
		}
		return menuInfoList;
	}

	/**
	 * 解析包房
	 *
	 * @param jsonObject jsonObject
	 * @return 房间列表
	 */
	private List<RoomInfo> parseRoomJson(JSONObject jsonObject)
	{
		ArrayList<RoomInfo> roomInfoList = new ArrayList<RoomInfo>();
		JSONObject obj = jsonObject.optJSONObject("room_status_map");
		JSONArray jsonArray = jsonObject.optJSONArray("list");
		if (jsonArray != null && jsonArray.length() > 0)
		{
			for (int i = 0; i < jsonArray.length(); i++)
			{
				JSONObject jObject = jsonArray.optJSONObject(i);
				if (jObject == null)
					continue;
				RoomInfo info = new RoomInfo();
				info.setFlick(1 == jObject.optInt("is_on_service"));
				info.setRoomId(jObject.optString("room_id"));
				info.setRoomNum(jObject.optString("room_code"));
				info.setRoomType(jObject.optString("room_type_name"));
				info.setRoomPeopleCount(jObject.optInt("customer_count"));
				info.setRoomRemark(jObject.optString("remarks"));
				info.setRoomStatus(jObject.optString("room_status"));
				info.setRoomStatusCn(obj.optString(jObject.optString("room_status")));
				String bill_status = jObject.optString("bill_status");
				info.setBillStatus(bill_status);
				info.setStart_time(jObject.optString("bill_begin_time"));
				info.setEnd_time(jObject.optString("bill_end_time"));
				//				if (TextUtils.equals(bill_status, "paied"))//账单状态为已支付
				//					info.setEnd_time(jObject.optString("bill_end_time"));
				//				else if (TextUtils.equals(bill_status, "paying") || TextUtils.equals(bill_status, "unpaied"))//账单状态为支付中，未支付
				//					info.setEnd_time(jObject.optString("expected_time"));
				info.setBillId(jObject.optString("bill_id"));
				info.setUsage(jObject.optString("usage"));
				info.setIsHonor(jObject.optInt("is_honor"));
				info.setChargingRoomTypeId(jObject.optString("charging_room_type_id"));
				info.setType(0);
				info.setCustom(false);
				roomInfoList.add(info);
			}
		}
		return roomInfoList;
	}

	/**
	 * 解析桌台
	 *
	 * @param jsonObject jsonObject
	 * @return 桌台列表
	 */
	private List<RoomInfo> parseDeskJson(JSONObject jsonObject)
	{
		ArrayList<RoomInfo> roomInfoList = new ArrayList<RoomInfo>();
		JSONArray jsonArray = jsonObject.optJSONArray("list");
		if (jsonArray != null && jsonArray.length() > 0)
		{
			for (int i = 0; i < jsonArray.length(); i++)
			{
				JSONObject jObject = jsonArray.optJSONObject(i);
				if (jObject == null)
					continue;
				RoomInfo info = new RoomInfo();
				info.setRoomId(jObject.optString("desk_id"));
				info.setRoomNum(jObject.optString("desk_code"));
				info.setDesk_type_id(jObject.optString("desk_type_id"));
				info.setRoomType(jObject.optString("desk_type_name"));
				info.setRoomRemark(jObject.optString("remarks"));
				info.setRoomStatus(jObject.optString("desk_status"));
				info.setStart_time(jObject.optString("begin_time"));
				info.setEnd_time(jObject.optString("end_time"));
				info.setBillId(jObject.optString("bill_id"));
				info.setAbs_number(jObject.optInt("abs_number"));
				info.setRoomPeopleCount(jObject.optInt("customer_count"));
				info.setType(1);
				info.setCustom(false);
				roomInfoList.add(info);
			}
		}
		return roomInfoList;
	}

	/**
	 * 解析区域
	 *
	 * @param jsonObject jsonObject
	 */
	private void parseAreaJson(JSONObject jsonObject)
	{
		ArrayList<PartInfo> partInfoList = new ArrayList<PartInfo>();
		ArrayList<PartInfo> partOldList = (ArrayList<PartInfo>) PartInfoDao.getDao().queryAll(PartInfo.class);
		JSONArray jsonArray = jsonObject.optJSONArray("areas");
		if (jsonArray != null && jsonArray.length() > 0)
		{
			for (int i = 0; i < jsonArray.length(); i++)
			{
				JSONObject jObject = jsonArray.optJSONObject(i);
				if (jObject == null)
					continue;
				PartInfo info = new PartInfo();
				info.setPart_id(jObject.optString("area_id"));
				info.setPartName(jObject.optString("name"));
				info.setRoomSelect(true);
				info.setTableSelect(true);
				partInfoList.add(info);
			}
			try
			{
				if (!CollectionUtils.isEmpty(partOldList))
				{
					for (int i = 0; i < partOldList.size(); i++)
					{
						PartInfo OldInfo = partOldList.get(i);
						for (int j = 0; j < partInfoList.size(); j++)
						{
							PartInfo info = partInfoList.get(j);
							if (TextUtils.equals(OldInfo.getPart_id(), info.getPart_id()))
							{
								info.setRoomSelect(OldInfo.isRoomSelect());
								info.setTableSelect(OldInfo.isTableSelect());
								break;
							}
						}
					}
					PartInfoDao.getDao().clearTable(PartInfo.class);
					PartInfoDao.getDao().insertAll(PartInfo.class, partInfoList);
				} else
				{
					PartInfoDao.getDao().insertAll(PartInfo.class, partInfoList);
				}
			} catch (Exception e)
			{
				e.printStackTrace();
			}
		}
	}

	/**
	 * 解析商品
	 *
	 * @param jsonObject jsonObject
	 * @param roomId     房间id
	 * @param menuId     菜单id
	 * @param bill_id    账单id
	 * @return 房间列表
	 */
	private List<GoodsInfo> parseGoodsJson(JSONObject jsonObject, String roomId, String menuId, String bill_id)
	{
		ArrayList<GoodsInfo> foodInfoList = new ArrayList<GoodsInfo>();
		JSONArray jsonArray = jsonObject.optJSONArray("list");
		if (jsonArray != null && jsonArray.length() > 0)
		{
			int disPrice = -1;
			for (int i = 0; i < jsonArray.length(); i++)
			{
				JSONObject jObject = jsonArray.optJSONObject(i);
				if (jObject == null)
					continue;
				GoodsInfo info = new GoodsInfo();
				info.setRoomId(roomId);
				info.setBillId(bill_id);
				//0商品 1活动 注意：这里展示的时候商品类型和购物车数据库存的时候的商品类型不一样
				if (0 == jsonObject.optInt("is_active"))
				{
					info.setMenuId(jObject.optString("menu_type_id"));
					info.setGoodsId(jObject.optString("goods_id"));
					info.setSurplus(jObject.optInt("rest"));
					info.setGoodsName(jObject.optString("cn_name"));
					info.setUnit(jObject.optString("unit"));
					info.setOperateTypeId(jObject.optString("operate_type_id"));
					info.setOriginalPrice(jObject.optInt("branch_price"));//门店价
					JSONArray array = jObject.optJSONArray("taste_types");
					if (array != null && array.length() > 0)
						info.setTaste_types(array.toString());
					JSONArray standard = jObject.optJSONArray("standard_type");
					if (standard != null && standard.length() > 0)
						info.setStandard_types(standard.toString());
					disPrice = jObject.optInt("discount_price");
					if (disPrice > 0)
					{
						info.setDiscountPrice(disPrice);
						info.setPrice(disPrice);//优惠价
					} else
						info.setPrice(jObject.optInt("branch_price"));//门店价
					JSONArray bundle = jObject.optJSONArray("combos");
					info.setGoods_type(bundle != null && bundle.length() > 0 ? VodConstant.BUNDLE_TYPE : VodConstant.RETAIL_TYPE);
					info.setGoodsDetial(bundle != null && bundle.length() > 0 ? bundle.toString() : "");
				} else
				{
					info.setGoodsId(jObject.optString("active_id"));
					info.setGoodsName(jObject.optString("alias"));
					info.setPrice(jObject.optInt("sale_price"));
					info.setUnit(jObject.optString("unit"));
					JSONArray actives = jObject.optJSONArray("goods");
					info.setGoodsDetial((actives != null && actives.length() > 0) ? actives.toString() : "");
					info.setDecrease_time(jObject.optInt("decrease_time"));
					info.setGoods_type(VodConstant.ACTIVE_TYPE);
				}
				foodInfoList.add(info);
			}
		}
		return foodInfoList;
	}

	/**
	 * 获取规格价
	 *
	 * @return
	 */
	private int getStandardPrice(JSONArray standard)
	{
		int price = -1;
		if (standard != null && standard.length() > 0)
		{
			List<Integer> list = new ArrayList<Integer>();
			for (int i = 0; i < standard.length(); i++)
			{
				JSONObject object = standard.optJSONObject(i);
				JSONArray array = object.optJSONArray("standard");
				if (array != null && array.length() > 0)
				{
					for (int j = 0; j < array.length(); j++)
					{
						JSONObject jsonObject = array.optJSONObject(j);
						list.add(jsonObject.optInt("price"));
					}
				}
			}
			price = MaxIntegerUtil.getMaxNumber(list);
		}
		return price;
	}

	/**
	 * 解析商品详情
	 *
	 * @param object jsonObject
	 */
	private GoodsInfo parseGoodsDetailJson(JSONObject object, String roomId)
	{
		GoodsInfo info = new GoodsInfo();
		info.setRoomId(roomId);
		JSONObject jsonObject = object.optJSONObject("goods_info");
		if (null == jsonObject)
			return null;
		info.setMenuId(jsonObject.optString("menu_type_id"));
		info.setGoodsId(jsonObject.optString("goods_id"));
		info.setSurplus(jsonObject.optInt("rest"));
		info.setGoodsName(jsonObject.optString("cn_name"));
		int disPrice = jsonObject.optInt("discount_price");
		if (disPrice > 0)
		{
			info.setDiscountPrice(disPrice);
			info.setPrice(disPrice);//优惠价
		} else
			info.setPrice(jsonObject.optInt("branch_price"));//门店价
		info.setUnit(jsonObject.optString("unit"));
		JSONArray standard = jsonObject.optJSONArray("standard_type");
		if (standard != null && standard.length() > 0)
		{
			info.setStandard_types(standard.toString());
		}
		JSONArray taste = jsonObject.optJSONArray("taste_types");
		if (taste != null && taste.length() > 0)
		{
			info.setTaste_types(taste.toString());
		}
		JSONArray array = jsonObject.optJSONArray("combos");
		if (array != null && array.length() > 0)
		{
			info.setGoodsDetial(array.toString());
		}
		JSONArray array_group_goods = object.optJSONArray("group_goods");
		//商品关联组
		if (array_group_goods != null && array_group_goods.length() > 0)
		{
			int len = array_group_goods.length();
			for (int i = 0; i < len; i++)
			{
				JSONObject jsonObject1 = array_group_goods.optJSONObject(i);
				if (null == jsonObject1)
				{
					return info;
				}
				GroupGoodsInfo groupGoodsInfo = new GroupGoodsInfo();
				groupGoodsInfo.setName(jsonObject1.optString("cn_name"));
				groupGoodsInfo.setGoodsId(jsonObject1.optString("goods_id"));
				info.getGroupGoodsInfoList().add(groupGoodsInfo);
			}
		}
		return info;
	}

	/**
	 * 解析活动详情
	 *
	 * @param jsonOb jsonObject
	 */
	private GoodsInfo parseActiveDetailJson(JSONObject jsonOb, String roomId)
	{
		GoodsInfo info = new GoodsInfo();
		JSONObject jsonObject = jsonOb.optJSONObject("active_info");
		if (null == jsonObject)
			return null;
		info.setRoomId(roomId);
		info.setGoodsId(jsonObject.optString("active_id"));
		info.setDecrease_time(jsonObject.optInt("decrease_time"));
		info.setDecrease_value(jsonObject.optInt("decrease_value"));
		info.setGoodsName(jsonObject.optString("alias"));
		info.setPrice(jsonObject.optInt("sale_price"));
		info.setUnit(jsonObject.optString("unit"));
		JSONArray array = jsonObject.optJSONArray("goods");
		JSONArray array_group_goods = jsonOb.optJSONArray("group_actives");
		if (array != null && array.length() > 0)
		{
			info.setGoodsDetial(array.toString());
		}
		//商品关联组
		if (array_group_goods != null && array_group_goods.length() > 0)
		{
			int len = array_group_goods.length();
			for (int i = 0; i < len; i++)
			{
				JSONObject jsonObject1 = array_group_goods.optJSONObject(i);
				if (null == jsonObject1)
				{
					return info;
				}
				GroupGoodsInfo groupGoodsInfo = new GroupGoodsInfo();
				groupGoodsInfo.setName(jsonObject1.optString("name"));
				groupGoodsInfo.setActiveId(jsonObject1.optString("active_id"));
				info.getGroupGoodsInfoList().add(groupGoodsInfo);
			}
		}
		return info;
	}

	/**
	 * 解析点餐查询信息
	 *
	 * @param jsonObject jsonObject
	 */
	private List<OrderInfo> parseOrderQueryJson(JSONObject jsonObject)
	{
		ArrayList<OrderInfo> infoList = new ArrayList<OrderInfo>();
		JSONArray jsonArray = jsonObject.optJSONArray("bill_flows");
		if (jsonArray != null && jsonArray.length() > 0)
		{
			for (int i = 0; i < jsonArray.length(); i++)
			{
				OrderInfo info = new OrderInfo();
				try
				{
					JSONObject object = jsonArray.getJSONObject(i);
					info.setBill_channel(object.optString("bill_channel"));
					info.setFlow_code(object.optString("flow_code"));
					info.setFlow_time(object.optString("flow_time"));
					info.setTotal_price(object.optInt("total_price"));
					info.setOrderId(object.optString("order_id"));
					info.setPay_status(object.optInt("pay_status"));
					JSONArray retails = object.optJSONArray("retails");
					if (retails != null && retails.length() > 0)
					{
						info.setRetails(retails.toString());
					}
					JSONArray bundles = object.optJSONArray("bundles");
					if (bundles != null && bundles.length() > 0)
					{
						info.setBundles(bundles.toString());
					}
					JSONArray actives = object.optJSONArray("actives");
					if (actives != null && actives.length() > 0)
					{
						info.setActives(actives.toString());
					}
					JSONObject jsonObject1 = object.optJSONObject("backgoods");
					if (jsonObject1 != null)
					{
						info.setBackgoods(jsonObject1.toString());
					}
					infoList.add(info);
				} catch (JSONException e)
				{
					e.printStackTrace();
				}
			}
		}
		return infoList;
	}

	/**
	 * 解析 点餐外带历史
	 *
	 * @param jsonObject jsonObject
	 */
	private List<OrderInfo> parseOrderTakeOutHistoryList(JSONObject jsonObject)
	{
		ArrayList<OrderInfo> infoList = new ArrayList<OrderInfo>();
		JSONArray jsonArray = jsonObject.optJSONArray("histories");
		if (jsonArray != null && jsonArray.length() > 0)
		{
			for (int i = 0; i < jsonArray.length(); i++)
			{
				OrderInfo info = new OrderInfo();
				try
				{
					JSONObject object = jsonArray.getJSONObject(i);
					info.setBill_channel(object.optString("bill_channel"));
					info.setFlow_code(object.optString("outer_flow_id"));//外带流水号
					info.setFlow_time(object.optString("ack_time"));//下单时间
					info.setOrderId(object.optString("outer_flow_id"));//外带流水号

					info.setTotal_price(object.optInt("total_price"));//无返回
					info.setPay_status(object.optInt("pay_status"));//无返回

					JSONArray foods = object.optJSONArray("foods");
					if (foods != null && foods.length() > 0)
					{
						JSONArray arrayRetail = new JSONArray();
						JSONArray arrayBundle = new JSONArray();
						int lenthRetail = 0;
						int lenthBundle = 0;
						int len = foods.length();
						for (int j = 0; j < len; j++)
						{
							JSONObject object1 = foods.optJSONObject(j);
							if (null != object1)
							{
								JSONArray array = object1.optJSONArray("goods");
								if (null != array && array.length() > 0)
								{//这是套餐
									arrayBundle.put(lenthBundle, foods.optJSONObject(j));
									lenthBundle++;
								} else
								{//这是单品
									arrayRetail.put(lenthRetail, foods.optJSONObject(j));
									lenthRetail++;
								}
							}
						}
						info.setRetails(arrayRetail.toString());
						info.setBundles(arrayBundle.toString());
					}
					infoList.add(info);
				} catch (JSONException e)
				{
					e.printStackTrace();
				}
			}
		}
		return infoList;
	}

	/**
	 * 解析备注查询信息
	 * @param jsonObject
	 * @return
	 */
	private List<RoomInfo> parseRemarkJson(JSONObject jsonObject)
	{
		ArrayList<RoomInfo> roomInfoList = new ArrayList<RoomInfo>();
		JSONArray jsonArray = jsonObject.optJSONArray("list");
		if (jsonArray != null && jsonArray.length() > 0)
		{
			for (int i = 0; i < jsonArray.length(); i++)
			{
				JSONObject jObject = jsonArray.optJSONObject(i);
				if (jObject == null)
					continue;
				RoomInfo info = new RoomInfo();
				info.setRoomNum(jObject.optString("room_code"));
				info.setRoomRemark(jObject.optString("remarks"));
				info.setRoomStatus(jObject.optString("room_status"));
				info.setRoomPeopleCount(jObject.optInt("prepay_amount"));
				info.setUsage(jObject.optString("usage"));
				roomInfoList.add(info);
			}
		}
		return roomInfoList;
	}

	/**
	 * 解析点餐预结列表
	 *
	 * @return
	 */
	private List<RoomInfo> parseExectedList(JSONObject jsonObject)
	{
		if (jsonObject == null)
			return null;
		ArrayList<RoomInfo> infoList = new ArrayList<RoomInfo>();
		JSONArray jsonArray = jsonObject.optJSONArray("list");
		if (jsonArray != null && jsonArray.length() > 0)
		{
			for (int i = 0; i < jsonArray.length(); i++)
			{
				JSONObject jsonObject1 = jsonArray.optJSONObject(i);
				if (null != jsonObject1)
				{
					RoomInfo info = new RoomInfo();
					info.setRoomNum(jsonObject1.optString("room_code"));
					info.setRoomId(jsonObject1.optString("room_id"));
					info.setRest(jsonObject1.optInt("rest"));
					infoList.add(info);
				}
			}
		}
		return infoList;
	}

	/**
	 * 解析消费办法图片列表
	 *
	 * @return 消费办法图片列表
	 */
	private List<PhotoDetailInfo> parsePictureList(JSONObject jsonObject)
	{
		if (jsonObject == null)
			return null;
		ArrayList<PhotoDetailInfo> list = new ArrayList<PhotoDetailInfo>();
		JSONArray jsonArray = jsonObject.optJSONArray("images");
		if (jsonArray != null && jsonArray.length() > 0)
		{
			int lenth = jsonArray.length();
			for (int i = 0; i < lenth; i++)
			{
				String url = jsonArray.optString(i);
				if (!TextUtils.isEmpty(url))
				{
					PhotoDetailInfo photoDetailInfo = new PhotoDetailInfo();
					photoDetailInfo.setUrl(ServerConfig.serverIp+url);
					list.add(photoDetailInfo);
				}
			}
		}
		return list;
	}
}
